package com.yanqu.road.server.cmd.newmonopolymkt;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.newmonopolymkt.NewMonopolyMarketProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.newmonopolymkt.NewMonopolyMarketModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.systemgroup.newmonopolymarket.NewMonopolyMarketMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

import java.util.List;


@Cmd(code = GameProtocol.S_NEW_MONOPOLY_MARKET_RESET_SYSTEM, desc = "通知区服活动结束重置数据 跨服返回区服 协议")
public class NewMonopolyMarketSynResetSystemCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        NewMonopolyMarketProto.NewMonopolyMarketResetToGameServerMsg synMsg = NewMonopolyMarketProto.NewMonopolyMarketResetToGameServerMsg.parseFrom(packet.getBytes());
        int bit = synMsg.getBit();
        if(bit <= 0){
            return;
        }
        List<GamePlayer> playerLis = GamePlayerMgr.getAllOnlinePlayer();
        for (GamePlayer player : playerLis) {
            player.getModule(NewMonopolyMarketModule.class).getUserData();
        }
        NewMonopolyMarketMgr.getLogger().info("收到榷场活动结束或者重置的标识 bit:{}",bit);
    }
}
